package learn_concurrent._4;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class T2 {
    static final Logger logger = LoggerFactory.getLogger(T2.class);

    static final Object lock = new Object();

    public static void main(String[] args) throws InterruptedException {

        new Thread(() -> {
            synchronized (lock) {
                logger.info("working...");
                try {
                    lock.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                logger.info("other work...");
            }
        }, "t1").start();

        new Thread(() -> {
            synchronized (lock) {
                logger.info("working...");
                try {
                    lock.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                logger.info("other work...");
            }
        }, "t2").start();

        Thread.sleep(1000);
        synchronized (lock) {
//			lock.notify();
            lock.notifyAll();
        }

    }

}
